import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TSweepUp } from "../../../Message/Db/Tables/TSweepUp";
import { DataProvider } from "../../../fl/data/DataProvider";
import { DelegateTaskData } from "../view/delegate/cell/DelegateTaskData";
type int = number;
//class ActiveDelegateConfig
    
    export  class ActiveDelegateConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (ActiveDelegateConfig._instance != null) 
            {
                throw new Error(" ActiveDelegateConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_sweep_up.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TSweepUp();
                loc1.code = loc2.code;
                loc1.condition = loc2.condition;
                loc1.conditionDesc = loc2.conditionDesc;
                loc1.experience = loc2.experience;
                loc1.gold = loc2.gold;
                loc1.id = loc2.id;
                loc1.levelLimit = loc2.levelLimit;
                loc1.reward = loc2.reward;
                this._map[loc1.id] = loc1;
            }
            this.initListData();
            return;
        }

        public ActiveDelegateConfig.get canActiveDelegateList(): DataProvider
        {
            if (this._canActiveDelegateList == null) 
            {
                this.initListData();
            }
            return this._canActiveDelegateList;
        }

        /* internal  */initListData(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            this._canActiveDelegateList = new DataProvider();
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc5=0;
            var loc6=this._map;
            for(loc2 of loc6) 
            {
                if (loc2.code == 162) 
                {
                    continue;
                }
                if (loc1[loc2.code] == null) 
                {
                    loc4 = new DelegateTaskData(loc2);
                    loc1[loc2.code] = loc4;
                    this._canActiveDelegateList.addItem(loc4);
                    continue;
                }
                loc3 = loc1[loc2.code];
                if (!(loc2.condition < loc3.tsweepUp.condition)) 
                {
                    continue;
                }
                loc3.tsweepUp = loc2;
            }
            return;
        }

        public getTSweepUpById(arg1: int): TSweepUp
        {
            return this._map[arg1];
        }

        public static get instance(): ActiveDelegateConfig
        {
            if (ActiveDelegateConfig._instance == null) 
            {
                ActiveDelegateConfig._instance = new ActiveDelegateConfig();
            }
            return ActiveDelegateConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_canActiveDelegateList: DataProvider;

        /* internal */ static /* var */_instance: ActiveDelegateConfig;
    }
